package com.crazybytex.modbus.beans;

import static com.crazybytex.modbus.Constant.RET_CODE_SUCCESS;

/**
 * @Author 程序员潇然 crazybytex.com
 * @Date 2022/8/3 17:23
 * @Description TODO
 **/
public class ModBusResponse {
    private int code;
    private String msg;

    public ModBusResponse() {
        code = RET_CODE_SUCCESS;
        msg="success";
    }

    public ModBusResponse(int code,String msg) {
        this.code = code;
        this.msg = msg;
    }

    /**
     * 解析返回的字节数组 转换为对应的实体类  默认什么都不做  需要处理子类进行
     * @param bytes 需要处理的字节数组
     */
    public void parse(byte[] bytes){

    }

    public int code() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String msg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }


    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("ModBusResponse{");
        sb.append("code=").append(code);
        sb.append(", msg='").append(msg).append('\'');
        sb.append('}');
        return sb.toString();
    }
}
